//
//  UIBarButtonItem+Extension.swift
//  SwiftWebo
//
//  Created by 王勇 on 2018/5/27.
//  Copyright © 2018年 Brave. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    
    /// 自定义 创建UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: 默认16号
    ///   - target: target
    ///   - action: action
    ///便利构造函数
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject?,action:Selector,isBack:Bool = false) {
        
       
        
        let btn: UIButton = UIButton(type: .roundedRect)
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.black, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
        // 是否是返回按钮
        if isBack {
//            let imageName = ""
//            btn.setImage(UIImage.init(named: imageName), for: .normal)
//            btn.setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)

        }
        btn.sizeToFit()
        //self.init 实例化UIBarButtonItem
        self.init(customView: btn)
        
    }
    
    
    
}
